<?php
include 'vendor/autoload.php';

use Sabre\HTTP;


$client = new HTTP\Client();

// Executing 100 requests
for ($i = 0; $i < 20; $i++) {
	$request = new HTTP\Request('GET', 'http://localhost/demo.php?index='.$i);
    $client->sendAsync(
        $request,
        function($response) {
            // Success handler
			echo $response->getBodyAsString();
			echo "\n";
        },
        function($error) {
            // Error handler
			var_dump($error);
        }
    );
}

// Wait for all requests to get a result.
$client->wait();